package com.book.shop.model;

import com.sun.istack.NotNull;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;

@Entity
@Data
@Table(name="orderitems")
public class OrderItems implements Serializable {
    private static final long serialVersionUID =1L;
    @Id
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "orderid")
    private Order order;
    @Id
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="bookid")
    private Book book;

    @NotNull
    @Column(name="quantity")
    private Long quantity;

    public OrderItems(Order order,Book book){
        this.order=order;
        this.book=book;
    }
    public OrderItems(Order order,Book book,Long quantity){
        this.order=order;
        this.book =book;
        this.quantity=quantity;
    }
    public OrderItems(){
    }
}
